/*
 * @Author: C.
 * @Date: 2023-03-27 10:57:33
 */
import { getTableMaps, getFormMaps } from '/~/utils/help/createFields';
import { buildUUID } from '/@/utils/uuid';
import { Progress } from 'ant-design-vue';
import { h } from 'vue';
export const tableColumns = getTableMaps([
  {
    title: '下拉框',
    dataIndex: 'name3',
    edit: true,
    editComponent: 'Select',
    editComponentProps: {
      options: [
        {
          label: 'Option1',
          value: '1',
        },
        {
          label: 'Option2',
          value: '2',
        },
      ],
    },
    width: 200,
  },
  {
    title: '数字输入框',
    dataIndex: 'age',
    edit: true,
    editRule: true,
    editComponent: 'InputNumber',
    width: 200,
    editComponentProps: () => {
      return {
        max: 100,
        min: 0,
      };
    },
    editRender: ({ text }) => {
      return h(Progress, { percent: Number(text) });
    },
  },
  {
    title: '日期选择',
    dataIndex: 'beginTime',
    edit: true,
    editComponent: 'DatePicker',
    editComponentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
    width: 200,
  },
  {
    title: '单选框',
    dataIndex: 'endTime',
    edit: true,
    editComponent: 'RadioGroup',
    editComponentProps: {
      options: [
        {
          label: '选项1',
          value: '1',
        },
        {
          label: '选项2',
          value: '2',
        },
      ],
    },
    width: 200,
  },
]);
export const formSchemas = getFormMaps(['Keyword', 'DatePeriod']);

export function createData(count = 1) {
  const arr: any = [];
  for (let index = 0; index < count; index++) {
    arr.push({
      id: buildUUID(),
      name: 'John Brown',
      age: `1${index}`,
      no: `${index + 10}`,
      address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
      beginTime: new Date().toLocaleString(),
      endTime: new Date().toLocaleString(),
      img: '/Files/1621411299151839234.png',
      name3: '555',
    });
  }
  return arr;
}
